const now = new Date();
const oneDay = 24 * 3600 * 1000;
let value = Math.random() * 1000;

function randomData() {
  now.setTime(now.getTime() + oneDay);
  value = value + Math.random() * 21 - 10;
  return {
    name: now.toString(),
    value: [
      [now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'),
      Math.round(value)
    ]
  };
}

const data = [];
for (let i = 0; i < 1000; i++) {
  data.push(randomData());
}

export default {
  title: {
    text: '乘车人数'
  },
  tooltip: {
    trigger: 'axis',
    formatter: function (params) {
      params = params[0];
      var date = new Date(params.name);
      return (
        date.getDate() +
        '/' +
        (date.getMonth() + 1) +
        '/' +
        date.getFullYear() +
        ' : ' +
        params.value[1]
      );
    },
    axisPointer: {
      animation: false
    }
  },
  xAxis: {
    type: 'time',
    splitLine: {
      show: false
    }
  },
  yAxis: {
    type: 'value',
    boundaryGap: [0, '100%'],
    splitLine: {
      show: false
    }
  },
  series: [
    {
      name: 'Dynamic Data',
      type: 'line',
      showSymbol: false,
      data: data
    }
  ]
};
